home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / sndhrdw / irem.c < prev    next >
C/C++ Source or Header  |  2000-04-10  |  3KB  |  131 lines

  1. #include "driver.h"
  2. #include "irem.h"
  3. #include "cpu/m6800/m6800.h"
  4.  
  5.  
  6.  
  7. WRITE_HANDLER( irem_sound_cmd_w )
  8. {
  9.     if ((data & 0x80) == 0)
  10.         soundlatch_w(0,data & 0x7f);
  11.     else
  12.         cpu_set_irq_line(1,0,HOLD_LINE);
  13. }
  14.  
  15.  
  16. static int port1,port2;
  17.  
  18. static WRITE_HANDLER( irem_port1_w )
  19. {
  20.     port1 = data;
  21. }
  22.  
  23. static WRITE_HANDLER( irem_port2_w )
  24. {
  25.     /* write latch */
  26.     if ((port2 & 0x01) && !(data & 0x01))
  27.     {
  28.         /* control or data port? */
  29.         if (port2 & 0x04)
  30.         {
  31.             /* PSG 0 or 1? */
  32.             if (port2 & 0x10)
  33.                 AY8910_control_port_1_w(0,port1);
  34.             else if (port2 & 0x08)
  35.                 AY8910_control_port_0_w(0,port1);
  36.         }
  37.         else
  38.         {
  39.             /* PSG 0 or 1? */
  40.             if (port2 & 0x10)
  41.                 AY8910_write_port_1_w(0,port1);
  42.             else if (port2 & 0x08)
  43.                 AY8910_write_port_0_w(0,port1);
  44.         }
  45.     }
  46.     port2 = data;
  47. }
  48.  
  49.  
  50. static READ_HANDLER( irem_port1_r )
  51. {
  52.     /* PSG 0 or 1? */
  53.     if (port2 & 0x10)
  54.         return AY8910_read_port_1_r(0);
  55.     else if (port2 & 0x08)
  56.         return AY8910_read_port_0_r(0);
  57.     else return 0xff;
  58. }
  59.  
  60.  
  61.  
  62. static WRITE_HANDLER( irem_adpcm_reset_w )
  63. {
  64.     MSM5205_reset_w(0,data & 1);
  65.     MSM5205_reset_w(1,data & 2);
  66. }
  67.  
  68. static WRITE_HANDLER( irem_adpcm_w )
  69. {
  70.     MSM5205_data_w(offset,data);
  71. }
  72.  
  73. static void irem_adpcm_int(int data)
  74. {
  75.     cpu_set_nmi_line(1,PULSE_LINE);
  76. }
  77.  
  78.  
  79. struct AY8910interface irem_ay8910_interface =
  80. {
  81.     2,    /* 2 chips */
  82.     910000,    /* .91 MHz ?? */
  83.     { 20, 20 },
  84.     { soundlatch_r, 0 },
  85.     { 0 },
  86.     { 0 },
  87.     { irem_adpcm_reset_w, 0 }
  88. };
  89.  
  90. struct MSM5205interface irem_msm5205_interface =
  91. {
  92.     2,                    /* 2 chips            */
  93.     384000,                /* 384KHz             */
  94.     { irem_adpcm_int, 0 },/* interrupt function */
  95.     { MSM5205_S96_4B,MSM5205_S96_4B},    /* 4KHz  */
  96.     { 100, 100 }
  97. };
  98.  
  99.  
  100.  
  101. struct MemoryReadAddress irem_sound_readmem[] =
  102. {
  103.     { 0x0000, 0x001f, m6803_internal_registers_r },
  104.     { 0x0080, 0x00ff, MRA_RAM },
  105.     { 0x4000, 0xffff, MRA_ROM },
  106.     { -1 }    /* end of table */
  107. };
  108.  
  109. struct MemoryWriteAddress irem_sound_writemem[] =
  110. {
  111.     { 0x0000, 0x001f, m6803_internal_registers_w },
  112.     { 0x0080, 0x00ff, MWA_RAM },
  113.     { 0x0801, 0x0802, irem_adpcm_w },
  114.     { 0x9000, 0x9000, MWA_NOP },    /* IACK */
  115.     { 0x4000, 0xffff, MWA_ROM },
  116.     { -1 }    /* end of table */
  117. };
  118.  
  119. struct IOReadPort irem_sound_readport[] =
  120. {
  121.     { M6803_PORT1, M6803_PORT1, irem_port1_r },
  122.     { -1 }    /* end of table */
  123. };
  124.  
  125. struct IOWritePort irem_sound_writeport[] =
  126. {
  127.     { M6803_PORT1, M6803_PORT1, irem_port1_w },
  128.     { M6803_PORT2, M6803_PORT2, irem_port2_w },
  129.     { -1 }    /* end of table */
  130. };
  131.